package com.qf.util;

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * 2019/12/7
 * Administrator
 * springboot1207
 * 面向对象面向君  不负代码不负卿
 */
//配置两个数据源
@Configuration
public class DatasourceA {

    //数据源A
    @Primary
    @Bean(name = "onedatasource")
    @ConfigurationProperties(prefix = "spring.datasource.one")
    public DataSource one(){ //连接chaoshi数据库
        return DataSourceBuilder.create().build();
    }

    //数据源B
    @Bean(name = "twodatasource")
    @ConfigurationProperties(prefix = "spring.datasource.two")
    public DataSource two(){//连接hunan 数据库
        return DataSourceBuilder.create().build();
    }

}
